<?php
$front_template = Zend_Registry::get('front_template');
//echo $this->headLink()->setStylesheet($this->baseUrl().'/js/jquery/pirobox/css_pirobox/demo5/style.css'); 
//echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/pirobox/pirobox.js');



echo $this->headLink()->setStylesheet($this->baseUrl().'/js/jquery/slider-pro/css/advanced-slider-base.css');
echo $this->headLink()->setStylesheet($this->baseUrl().'/js/jquery/slider-pro/css/prettyPhoto.css');
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/slider-pro/js/excanvas.compiled.js'); 
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/slider-pro/js/jquery.mousewheel.min.js'); 
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/slider-pro/js/jquery.prettyPhoto.custom.min.js'); 
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/slider-pro/js/jquery.easing.1.3.js'); 
echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/slider-pro/js/jquery.advancedSlider.js'); 

/*******MUST BE DYNAMIC*************************/
echo $this->headLink()->setStylesheet($this->baseUrl().'/js/jquery/slider-pro/skins/main/curved-square-'.$front_template['theme_folder'].'/curved-square-'.$front_template['theme_folder'].'.css');
echo $this->headLink()->setStylesheet($this->baseUrl().'/js/jquery/slider-pro/skins/scrollbar/scrollbar-7-light/scrollbar-7-light.css');


$global_conf = Zend_Registry::get('global_conf');
$currency = new Zend_Currency($global_conf['default_locale']);

if(!empty($this->view_datas['meta_keywords'])){ $this->headMeta()->setName('keywords',$this->view_datas['meta_keywords']); }
if(!empty($this->view_datas['meta_desc'])) { $this->headMeta()->setName('description',$this->view_datas['meta_desc']); }
if(!empty($this->view_datas['product_name'])) { $this->headTitle()->headTitle($this->escape($this->view_datas['product_name']),'SET')->setSeparator(' - ')->headTitle($this->view_datas['meta_title']); }
?>

<script type="text/javascript">	
	$(function() {
		$('#pro_list').hide('slow');
		$('a.toggle_pro').click(function() {
			var self = this;
			$('#pro_list').slideToggle(500,function () {
				var src = $(self).children("img").attr('src');
				var input = (src == 'application/layouts/scripts/<?php echo $front_template['theme_folder']; ?>/images/mod_img/minus.png') ? 'application/layouts/scripts/<?php echo $front_template['theme_folder']; ?>/images/mod_img/plus.png' : 'application/layouts/scripts/<?php echo $front_template['theme_folder']; ?>/images/mod_img/minus.png';
				$(self).children("img").attr('src',input);
			});
			return false;
		  });
		  
		  
	});
</script>

<div class="mod-gallery">
    <div class="gallery-icon">
        <h1><?php $menu_db_class = new Menu_Model_DbTable_Menu(); $menu_name = $menu_db_class->getMenuName($this->menu_id); echo $this->escape($this->view_datas['product_name']); ?></h1>
    </div>

	<div class="clear">&nbsp;</div>

    <div class="gallery">
        <!-- Category Panel Start -->
        <?php
        if($this->group_datas['category_panel'] == '1')
        {
                $categoryPanel = new Gallery_View_Helper_CategoryPanel();
                
        ?>
        <div class="category-panel">
        <a href="javascript:void(0);" class="toggle_pro toggle-link"><img src="application/layouts/scripts/<?php echo $front_template['theme_folder']; ?>/images/mod_img/plus.png" border="0" /><div class="toggle"><?php echo $this->translator->translator('gallery_frontend_common_category_list_title'); ?></div></a>
        <div id="pro_list" class="clear">
                <?php echo $categoryPanel->getCategories('0',$this,$this->group_datas['id'],null,$this->menu_id, $this->translator); ?>            
            </div>
        </div>
        <?php
            }
        ?>
        <!-- Category Panel End -->
        
        <?php if($this->group_datas['horizontal_panel'] == '1') { echo $this->partial('blocks/pathway.phtml'); } ?>
        
        <div class="gallery-container gallery-details">
            <?php
            if($this->group_datas['gallery_type'] == 'video' || $this->group_datas['gallery_type'] == 'music')
            {
                //echo $this->headScript()->appendFile($this->baseUrl().'/js/jquery/media/jquery.metadata.js');
                echo $this->headScript()->setFile($this->baseUrl().'/js/jquery/media/jquery.media.js');
                
                $product_file_val_arr = explode(',',$this->view_datas['product_file']);	
                                
            ?>
                <script type="text/javascript">
                    $(document).ready(function() {
                        $('.media_gallery').media({
                            width:		'<?php echo $this->escape($this->group_datas["img_big_width"]);?>',
                            height:		'<?php echo $this->escape($this->group_datas["img_big_height"]);?>',
                            flvPlayer:     'js/jquery/media/player.swf', 
                            mp3Player:     'js/jquery/media/player.swf'
                        });
                    });						
                </script>
                
                <table width="100%">
                    <tr>
                        <?php
                        if(!empty($this->view_datas['product_file']))
                        {
                            $cnt = 1;
                            foreach($product_file_val_arr as $key=>$value)
                            {
                                    $file_ext = Eicra_File_Utility::getExtension($this->escape($value));		
                                    $light_box_image = ($this->group_datas['gallery_type'] == 'video') ? $this->baseUrl().'/data/frontImages/gallery/video_file/'.$this->escape($value) : $this->baseUrl().'/data/frontImages/gallery/audio_file/'.$this->escape($value); 
                                    switch($file_ext)
                                    {
                                        case 'swf':
                                        case 'flv':
                                        case 'mp3':
                                            $href = 'js/jquery/media/mediaplayer.swf?file='.$light_box_image;
                                            break;
                                        case 'wmv':
                                        case 'avi':
                                        case 'mpg':
                                        case '3g2':
                                        case 'ram':										
                                            $href = $light_box_image;
                                            break;
                                        default:
                                            $href = $light_box_image;
                                            break;
                                    }
                            ?>
                            <td align="center" >
                                <a class="media_gallery" href="<?php echo $href; ?>"><?php echo $this->escape($value); ?></a>															
                            </td>
                            <?php
                                if($cnt % $this->escape($this->group_datas["file_col_num"]) == 0)
                                {
                                    echo '</tr><tr>';
                                }
                                $cnt++;
                            }
                         }
                         else
                         {
                        ?>
                            <td align="center">
                                <?php echo stripslashes($this->view_datas['product_desc']); ?>
                            </td>
                        <?php
                         }
                        ?>
                    </tr>
                </table>
            <?php
            }
            else
            {
            ?>
                <?php
                    $product_file_val_arr = explode(',',$this->view_datas['product_file']);
                    if($this->escape($this->view_datas['product_thumb_primary']))
                    { 
                        $thumb_image = 'data/frontImages/gallery/product_thumb/'.$this->escape($this->view_datas['product_thumb_primary']); 
                    }
                    else
                    { 
                        if($this->escape($this->view_datas['product_thumb']))
                        {
                            $product_thumb_val_arr = explode(',',$this->view_datas['product_thumb']);
                            $thumb_image = 'data/frontImages/gallery/product_thumb/'.$this->escape($product_thumb_val_arr[0]); 
                        }
                        else
                        {
                            if($this->escape($this->view_datas['product_file_primary']))
                            {
                                $thumb_image = 'data/frontImages/gallery/product_image/'.$this->escape($this->view_datas['product_file_primary']); 
                            }
                            else
                            {
                                $product_file_val_arr = explode(',',$this->view_datas['product_file']);
                                $thumb_image = 'data/frontImages/gallery/product_image/'.$this->escape($product_file_val_arr[0]); 
                            }
                        }		
                    }
                     
                    if($this->escape($this->view_datas['product_file_primary']))
                    {
                        $light_box_image = 'data/frontImages/gallery/product_image/'.$this->escape($this->view_datas['product_file_primary']); 
                    }
                    else
                    {
                        
                        $light_box_image = 'data/frontImages/gallery/product_image/'.$this->escape($product_file_val_arr[0]); 
                    }
                    
                     $title_data = '<b>'.$this->translator->translator('gallery_common_name').'</b> '.$this->escape($this->view_datas['product_name']); 
                     if($this->escape($this->view_datas['product_code']))
                     { 
                        $title_data .= '<br /><b>'.$this->translator->translator('gallery_common_code').' </b>'.$this->escape($this->view_datas['product_code']); 
                     } 
                     if($this->escape($this->view_datas['product_price']))
                     { 
                        $title_data .= ' <b>'.$this->translator->translator('gallery_common_price').'</b> '.$this->escape($this->view_datas['product_price']).' '.$currency->getSymbol(); 
                     }
                     if($this->escape($this->view_datas['product_desc']))
                     {  
                        $title_data .= '<br /><b>'.$this->translator->translator('gallery_common_desc').' </b>'.$this->escape(strip_tags($this->view_datas['product_desc']));
                     }
                    $title_data = html_entity_decode($title_data, ENT_QUOTES,"UTF-8"); 
                ?>
                <?php 						
                    if($this->group_datas['img_big_resize_func'] != 'OriginalSize')
                    {
                        if($this->group_datas['img_big_width'] && ($this->group_datas['img_big_resize_func'] == 'resizeToWidth' || $this->group_datas['img_big_resize_func'] == 'resize'))
                        { 
                            $width = 'width="'.$this->escape($this->group_datas['img_big_width']).'"'; 
                            $widthStyle = 'width:"'.$this->escape($this->group_datas['img_big_width']).'px;"'; 
                        } 
                        if($this->group_datas['img_big_height'] && ($this->group_datas['img_big_resize_func'] == 'resizeToHeight' || $this->group_datas['img_big_resize_func'] == 'resize'))
                        { 
                            $height = 'height="'.$this->escape($this->group_datas['img_big_height']).'"';
                            $heightStyle = 'height:"'.$this->escape($this->group_datas['img_big_height']).'px;"'; 
                        } 
                    }
                ?>
                
                <script type="application/javascript">
                    $(document).ready(function() {
                    /*****Slider Pro Start***************/
                      jQuery("#slider-pro-1").advancedSlider({
                                width: <?php echo $this->escape($this->group_datas['img_big_width']); ?>, 
                                height: <?php echo $this->escape($this->group_datas['img_big_height']); ?>, 
                                skin: 'curved-square-<?php echo $front_template['theme_folder']; ?>', 
                                scrollbarSkin: 'scrollbar-7-light', 
                                alignType: 'centerCenter', 
                                lightboxNavigation: 0, 
                                horizontalSlices: 7, 
                                verticalSlices: 4, 
                                fadeNavigationArrows: true, 
                                navigationButtonsNumbers: 1, 							 
                                thumbnailsType: 'navigation',
                                thumbnailWidth: <?php echo $this->escape($this->group_datas['file_thumb_width']); ?>,
                                thumbnailHeight:<?php echo $this->escape($this->group_datas['file_thumb_height']); ?>,
                                thumbnailSync: 1, 
                                thumbnailOrientation: 'horizontal', 
                                thumbnailArrows: 1, 
                                thumbnailScrollbar: 1, 
                                thumbnailMouseScroll: 1, 
                                thumbnailMouseWheel: 1,
                                fadeNavigationThumbnails:false,
                                navigationThumbnailsCenter:true,
                                thumbnailScrollDuration:1000,
                                thumbnailScrollEasing:'swing',
                                fadeThumbnailScrollbar:true,
                                fadeThumbnailArrows:true,
                                visibleThumbnails:5,
                                slideProperties:{
                                        0: {
                                                effectType: 'scale', 
                                                slicePattern: 'spiralMarginToCenterCW'
                                            }, 
                                        1: {
                                                effectType: 'fade', 
                                                horizontalSlices: 1, 
                                                verticalSlices: 1, 
                                                slideshowDelay: 10000
                                            }, 
                                        2: {
                                                effectType: 'slide', 
                                                horizontalSlices: 10, 
                                                verticalSlices: 1, 
                                                slicePattern: 'rightToLeft', 
                                                sliceDuration: 700
                                            }, 
                                        3: {
                                                effectType: 'height', 
                                                horizontalSlices: 10, 
                                                verticalSlices: 1, 
                                                slicePattern: 'leftToRight', 
                                                sliceDuration: 500, 
                                                slicePoint: 'rightBottom'
                                            }, 
                                        4: {
                                                effectType: 'scale', 
                                                sliceDuration: 800
                                            }, 
                                        5: {
                                                effectType: 'height', 
                                                horizontalSlices: 1, 
                                                verticalSlices: 10, 
                                                slicePattern: 'bottomToTop', 
                                                sliceDuration: 700, 
                                                slicePoint: 'centerTop'
                                            }, 
                                        6: {
                                                effectType: 'slide', 
                                                slicePattern: 'topLeftToBottomRight', 
                                                sliceDuration: 700, 
                                                slideStartPosition: 'rightBottom', 
                                                slideStartRatio: 0.5
                                            }, 
                                        7: {
                                                effectType: 'fade'
                                            }, 
                                        8: {
                                                effectType: 'slide', 
                                                horizontalSlices: 10, 
                                                verticalSlices: 1, 
                                                slicePattern: 'rightToLeft', 
                                                sliceDuration: 800, 
                                                slideStartPosition: 'verticalAlternativ'
                                            }
                                        }
                        });
                     /*****Slider Pro End***************/
                    });
                </script>
                
                <!-- Begin content -->
                <div id="content_wrapper">
                    
                    <div class="inner">
                    
                        <!-- Begin main content -->
                        <div class="inner_wrapper">
                            
                            <div style="width: 898px;  margin: 0px auto 10px; text-shadow: none;">
                                    <div id="slider-pro-1">
                                        <?php
                                            foreach($product_file_val_arr as $product_file_val_key => $product_file)
                                            {
                                        ?>
                                                <div class="slider-item">
                                                    <a href="#">
                                                        <img src="data/frontImages/gallery/product_image/<?php echo $product_file;?>"  alt="<?php echo html_entity_decode($this->escape($this->view_datas['product_name'])) ?>" border="0" />
                                                    </a>
                                                <div class="caption"><?php echo html_entity_decode($this->escape($title_data)); ?></div>
                                                    <div class="html"><?php //echo html_entity_decode($this->escape($this->view_datas['product_name'])) ?></div>
                                                    <img class="thumbnail" src="data/frontImages/gallery/product_image/<?php echo $product_file; ?>" alt="<?php echo html_entity_decode($this->escape($this->view_datas['product_name'])) ?>" title="<?php echo html_entity_decode($this->escape($this->view_datas['product_name'])) ?>" />
                                                     <div class="thumbnailTooltip"><?php echo html_entity_decode($this->escape($this->view_datas['product_name'])); ?></div>
                                                     <a class="lightbox" href="data/frontImages/gallery/product_image/<?php echo $product_file; ?>" title="<?php echo html_entity_decode($this->escape($this->view_datas['product_name'])); ?>"><?php echo  html_entity_decode($this->escape($this->view_datas['product_name'])); ?></a>
                                                </div>
                                        <?php
                                            }
                                        ?>
                                    </div>
                            </div>	
                                    
                        </div>
                        <!-- End main content -->
                        
                        <br class="clear">
                    </div>
                    
                </div>
                <!-- End content -->	
                
                <!-- Product Details Start-->
                <div class="product-details">
                    <?php echo $this->escape($this->view_datas['product_desc']) ?>
                </div>
                <!-- Product Details End-->
            <?php
            }
            ?>
        </div>
        
        <div class="clear">&nbsp;</div>
        <?php if($this->related_products){ ?>
        <div class="gallery-container related">
            <div class="related-title"><?php echo $this->translator->translator('gallery_frontend_details_related_pictures'); ?></div>
                <?php			
                    foreach($this->related_products as $related_products_key => $related_items)
                    {
                        $active_class = ($related_items['id'] == $this->view_datas['id']) ? 'active' : '';
                        if($this->escape($related_items['product_thumb_primary']))
                        { 
                            $thumb_image = 'data/frontImages/gallery/product_thumb/'.$this->escape($related_items['product_thumb_primary']); 
                        }
                        else
                        { 
                            if($this->escape($related_items['product_thumb']))
                            {
                                $product_thumb_val_arr = explode(',',$related_items['product_thumb']);
                                $thumb_image = 'data/frontImages/gallery/product_thumb/'.$this->escape($product_thumb_val_arr[0]); 
                            }
                            else
                            {
                                if($this->escape($related_items['product_file_primary']))
                                {
                                    $thumb_image = 'data/frontImages/gallery/product_image/'.$this->escape($related_items['product_file_primary']); 
                                }
                                else
                                {
                                    $product_file_val_arr = explode(',',$related_items['product_file']);
                                    $thumb_image = 'data/frontImages/gallery/product_image/'.$this->escape($product_file_val_arr[0]); 
                                }
                            }		
                        }
                        $link = $this->url( array('module' => 'Gallery','controller' =>'frontend','action' => 'productdetails','menu_id' => $this->escape($this->menu_id),'product_title' => $this->escape($related_items['product_title']) ), 'Details/:menu_id/:product_title',    false);
                ?>
                <div class="image-box <?php echo $active_class; ?>">
                  <div class="gallery-thumb related-thumb"><a class="preview" href="<?php echo $link; ?>" title="<?php echo $this->escape($related_items['product_name']); ?>" link="<?php echo $thumb_image; ?>" width="200"><img src="<?php echo $thumb_image; ?>" width="80" border="0" class="thumb-img" title=""></a></div>
                </div>
                <?php
                    }			
                ?>
        </div>
        <?php } ?>
        <!-- Getting All Comments from Comment Module and Add Comment Form -->
        <?php 
            $allCommentObj = new Comment_View_Helper_RepliedComment($this);
            echo $allCommentObj->getAllActiveComments('gallery_product',$this->escape($this->view_datas['id']));		
        ?>
        <!-- End of Getting All Comments from Comment Module Add Comment Form -->
    </div>
</div>